package com.ys.nms.module.business.controller.admin.redData;

import lombok.Data;
import java.util.List;

@Data
public class RrdQueryResult {
    private Boolean success;
    private String message;
    private List<RrdDataPoint> dataPoints;
    private RrdQueryParams queryParams;
    private Integer totalPoints;
    private Integer validPoints;

    public RrdQueryResult(List<RrdDataPoint> dataPoints, RrdQueryParams queryParams) {
        this.success = true;
        this.message = "查询成功";
        this.dataPoints = dataPoints;
        this.queryParams = queryParams;
        this.totalPoints = dataPoints.size();
        this.validPoints = (int) dataPoints.stream().filter(RrdDataPoint::isValid).count();
    }

    public RrdQueryResult(String errorMessage, RrdQueryParams queryParams) {
        this.success = false;
        this.message = errorMessage;
        this.dataPoints = List.of();
        this.queryParams = queryParams;
        this.totalPoints = 0;
        this.validPoints = 0;
    }
}